<?php
require_once(dirname(__FILE__).'/../include/config.inc.php');
header('Content-type: application/json;charset=utf-8');
$url=$_GET['url'];
$aa="";
if(empty($url)){
	$errno=array('errno'=>-1);
}else{
	$aa=checkURL($url);
	$errno=array('errno'=>$aa);
	if($aa==0){
		$msg="访问正常";
	}
	if($aa==1){
		$msg="网址被拦截";
	}
}
$json_json=array_merge($errno,array('msg'=>$msg));
$data=json_encode($json_json);
echo $data;


// 检测URL的返回值

function checkURL($url){
	if(isset($url)){
		$ch = curl_init();
		curl_setopt($ch, CURLOPT_URL, $url);
		curl_setopt($ch, CURLOPT_HEADER, 1);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);//这个是重点。
		//curl_setopt($ch, CURLOPT_POST, 1);
		//curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
		$html = curl_exec($ch);
		$num=strpos($html,'weixin110.qq.com');
		if($num>0){
			$errno='1';
		}else{
			$errno='0';
		}
		return $errno;
	}
}